%%%-------------------------------------------------------------------
%%% @author 25232
%%% @copyright (C) 2025, <COMPANY>
%%% @doc
%%%
%%% @end
%%% Created : 11. 11月 2025 21:09
%%%-------------------------------------------------------------------
-module(redis_encode_test).
-author("25232").

-include_lib("eunit/include/eunit.hrl").
-include("redis_driver.hrl").

%%write_to_file(Msg, Args) ->
%%  {ok, File} = file:open("redis.log", [append]),
%%  io:fwrite(File, Msg, Args),
%%  file:close(File).

encode_test() ->
  CmdList = [<<"setlist">>, <<"key">>, [<<"value2e\r\newrwer">>, <<"value">>]],
  CmdBin = <<"*3\r\n$7\r\nsetlist\r\n$3\r\nkey\r\n*2\r\n$15\r\nvalue2e\r\newrwer\r\n$5\r\nvalue\r\n">>,
  CheckBin = redis_encode:encode(CmdList),
  ?assertEqual(CheckBin, CmdBin),
  {ok, CheckCmdList, _PState} = redis_decode:decode(#pstate{rest_bin = CheckBin}),
  ?assertEqual(CheckCmdList, CmdList),
  ok.
